using System;
using System.Collections.Generic;
using System.Text;

namespace WCFServer.BusinessLogic
{
    public class PlayingPlayer
    {
        public PlayingPlayer()
        {
            Nick = null;
            LastCard = new Card();
            State = PlayerState.NotPlaying;
            round = 0;
        }

        public PlayingPlayer(string Nick,WCFServer.BusinessLogic.Card LastCard, int round, PlayerState state)
        {
            this.Nick = Nick;
            this.LastCard = LastCard;
            this.round = round;
            this.State = state;
        }

        private string NickField;

        public string Nick
        {
            get { return NickField; }
            set { NickField = value; }
        }

        private Card LastCardField;

        public Card LastCard
        {
            get { return LastCardField; }
            set { LastCardField = value; }
        }

        private PlayerState StateField;

        public PlayerState State
        {
            get { return StateField; }
            set { StateField = value; }
        }

        private int roundField;

        public int round
        {
            get { return roundField; }
            set { roundField = value; }
        }

        private int pointsField;

        public int points
        {
            get { return pointsField; }
            set { pointsField = value; }
        }

        public enum PlayerState
        {
            Won,
            Lost,
            NotPlaying,
            Faulted,
            Playing
        }

        public class playerCardsComparer : IComparer<PlayingPlayer>
        {
            #region IComparer<PlayingPlayer> Members

            public int Compare(PlayingPlayer x, PlayingPlayer y)
            {
                CardComparer comp = new CardComparer();

                return comp.Compare(x.LastCard, y.LastCard);
            }

            #endregion
        }

        public class playerPointsComparer : IComparer<PlayingPlayer>
        {

            #region IComparer<PlayingPlayer> Members

            public int Compare(PlayingPlayer x, PlayingPlayer y)
            {
                if (x == null)
                {
                    if (y == null)
                        return 0;
                    else
                        return -1;
                }
                else
                {
                    if (y == null)
                        return 1;
                    else
                    {
                        return x.points - y.points;
                    }
                }
            }

            #endregion
        }
    }
}
